var t = getApp();

Page({
  data: {
    addressBoo: !0,
    province: "",
    city: "",
    cityList: "",
    hospitalBoo: !0,
    hospitalCode: "",
    hospitalName: "",
    provinceListIndex: 0, //省下得市
    none: !0,
    Seng: "",
    SHI: "",
    url: "",
    provinceList: []
  },
  onLoad: function(options) {
    var that = this
    t.util.request({
      'url': 'entry/wxapp/address',
      data: {
        op: 'quyu'
      },
      success: function(res) {
        console.log(res)
        var quyu = res.data;
        that.setData({
          provinceList: res.data,
        })
      },
      fail: function(err) {
        console.log(err)
      },
    })
  },
  onShow: function() {
    this.setData({
      provinceBoo: !0
    });
    var t = wx.createAnimation({
      duration: 800,
      timingFunction: "ease"
    });
    this.animation = t;
  },
  choosearea: function() {
    this.animation.translateX(0).step();
    this.setData({
      addressBoo: !1,
      animationData: this.animation.export()
    });
  },
  tapProvince: function(t) {
    var e = this;
    e.setData({
      provinceIndex: t.target.dataset.index,
      provinceListIndex: t.target.dataset.index,
      province: t.target.dataset.province
    })
  },
  tapCity: function(t) {
    this.setData({
      city: ""
    });
    var id = t.target.id;
    var a = t.target.dataset.index,
      o = t.target.dataset.city,
      e = this.data.province;
    console.log(t.currentTarget.dataset.city), this.animation.translateX(1200).step(),
      this.setData({
        cityIndex: a,
        city: o,
        area: e + "-" + o,
        addressBoo: !0,
        animationData: this.animation.export(),
        hospitalName: "",
        SHI: t.currentTarget.dataset.city,
        id: id
      });
  },
  closesearea: function() {
    this.setData({
      textarea: !1
    }), this.animation.translateX(1200).step(), this.setData({
      addressBoo: !0,
      animationData: this.animation.export()
    });
  },
  chooseHospital: function(e) {
    console.log(e)
    let that = this;
    var id = e.currentTarget.dataset.id
    //查询下面的医院
    t.util.request({
      'url': 'entry/wxapp/address',
      data: {
        op: 'yiyuan',
        par_id: id
      },
      success: function(res) {
        console.log(res)
        var quyu = res.data;
        that.setData({
          hospitalList: res.data,
        })
      },
      fail: function(err) {
        console.log(err)
      },
    })
    this.setData({
      hospitalList: [],
      hospitalBoo: !1
    });
    let val = e.detail.value;
    let hospitalList = [];
    hospitalList
    if (val != '') {
      that.setData({
        hospitalList: hospitalList
      })
    }
  },
  choseHospital: function(t) {
    var a = this,
      o = a.data.hospitalList,
      e = t.target.dataset.hospitalcode,
      i = t.target.dataset.current;
    wx.setStorageSync("YY", o[i].name)
    console.log(o[i])
    a.setData({
      hospital: o[i].name,
      hospitalBoo: !0,
      id: o[i].id,
    });
  },
  hospitalSave: function(e) {
    console.log(e)
    var id = e.detail.target.id
    var name = e.detail.value.hospital
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    prevPage.setData({
      id: id,
      name: name
    })
    wx.navigateBack({
      delta: 1
    });
  }
});